package data;

public class File {
    private String name;
    private long size;
    private String filepath;
    private String type;
    private String hashedPassword;
    private String hashedCode;
    private boolean isProtected=false;
    private boolean isDeleted=false;
    private long fileID;
    
    /*
    GET*/
    public String getName()
    {
        return this.name;
    }

    public long getSize()
    {
        return this.size;
    }

    public String getFilepath()
    {
        return this.filepath;
    }

    public String getType()
    {
        return this.type;
    }

    public long getFileID()
    {
        return this.fileID;
    }

    public boolean isDeleted()
    {
        return this.isDeleted;
    }

    public boolean isProtected()
    {
        return this.isProtected;
    }

    public String getHashedCode()
    {
        return this.hashedCode;
    }
    
    public String getHashedPassword() {
        return hashedPassword;
    }
        
    /*
    SET
    */
    public void setName(String name)
    {
        this.name=name;
    }

    public void setSize(long size)
    {
        this.size=size;
    }

    public void setFilepath(String filepath)
    {
        this.filepath=filepath;
    }

    public void setType(String type)
    {
        this.type=type;
    }


    public void setFileID(long ID)
    {
        this.fileID=ID;
    }

    public void setProtected(boolean flag)
    {
        this.isProtected=flag;
    }

    public void setDeleted(boolean flag)
    {
        this.isDeleted=flag;
    }

    public void setHashedCode(String hashedCode)
    {
        this.hashedCode=hashedCode;
    }
    
    public void setHashedPassword(String hashedPassword) {
        this.hashedPassword = hashedPassword;
    }

    /*
    MISC
    */
    //Format number of bytes into human readable string
    public static String convertToMB(long numBytes)
    {
        if(numBytes<1024)
            return numBytes+" bytes";
            
        long mb=numBytes/(1024*1024);
        numBytes=numBytes%(1024*1024);
        long kb=numBytes/1024;
        numBytes=numBytes%1024;
        
        return mb+"."+String.format("%03d",kb)+" MB";
    }

    //Represent boolean as human readable strings
    public static String protectedFile(boolean isProtected){
        if(isProtected)
            return "Yes";
        else
            return "No";
    }

    //Represent boolean as human readable strings
    public static String deleteFile(boolean isDeleted){
        if(isDeleted)
            return "Yes";
        else
            return "No";
    }
}
